package Missiles;
import game.*;

import javax.swing.ImageIcon;
import java.lang.Math;

public class Missile extends FlyingObj implements Constants  //normal missiles
{  
    public int initX, initY;
    public int damage;  //the amount of hp deducted when hit by a missile
	
    public Missile(int x, int y, double angle, boolean upward) 
    /*initialize the position, and the direction; angle = arctan(x/y), constraints: -PI/6 < angle < PI/6
     grad = 0 if it fires vertically*/
    {
    	super();
        setImage(MISSILE);

        damage = 1;
        speed = 4;
        setX(x);
        setY(y);
        speedComponent(angle); 
        if (upward) //fired by the player
        	dy = -dy;
    }
    
    protected void speedComponent(double angle)
    {
    	dx = speed * Math.sin(angle);
        dy = speed * Math.cos(angle);

    }
    
    public void move()
    {
    	x = x + dx;
    	y = y + dy;
    }
}